﻿/* ***********************************************
 * Author		:  kingthy
 * Email		:  kingthy@gmail.com
 * Description	:  Trends
 *
 * ***********************************************/

using System;
using System.Collections.Generic;
using System.Text;
using OpenTwitter.SDK.Sina.Objects;

namespace OpenTwitter.SDK.Sina.API
{
    /// <summary>
    /// 与话题相关的API接口实现
    /// </summary>
    public class Trends
        : APIRequest
    {
        /// <summary>
        /// 根据授权对象实例化
        /// </summary>
        /// <param name="oauth"></param>
        public Trends(OAuth oauth)
            : base(oauth)
        { }


        #region 获取某用户关注的话题
        /// <summary>
        /// 采用默认API获取某用户关注的话题
        /// </summary>
        /// <param name="user_id">用户的UID</param>
        /// <param name="page_number">页码</param>
        /// <param name="page_count">每页返回的记录数量</param>
        /// <returns>话题数据</returns>
        public UserTrendData GetUserTrends(long user_id, int page_number, int page_count)
        {
            return this.GetUserTrends("http://api.t.sina.com.cn/trends", user_id, page_number, page_count);
        }
        /// <summary>
        /// 获取某用户关注的话题
        /// </summary>
        /// <param name="requestUrl">API请求地址</param>
        /// <param name="user_id">用户的UID</param>
        /// <param name="page_number">页码</param>
        /// <param name="page_count">每页返回的记录数量</param>
        /// <returns>话题数据.</returns>
        public UserTrendData GetUserTrends(string requestUrl, long user_id, int page_number, int page_count)
        {;
            this.Clear();
            this.Parameters.Add("user_id", user_id);
            this.Parameters.Add("page", page_number);
            this.Parameters.Add("count", page_count);
            return this.GetResponseData<UserTrendData>(requestUrl);
        }
        #endregion

        #region 获取某话题下的微博数据
        /// <summary>
        /// 采用默认API获取某话题下的微博数据
        /// </summary>
        /// <param name="trend_name">话题关键词</param>
        /// <returns>话题数据</returns>
        public TimelineData GetTrends(string trend_name)
        {
            return this.GetTrends("http://api.t.sina.com.cn/trends/statuses", trend_name);
        }
        /// <summary>
        /// 获取某话题下的微博数据
        /// </summary>
        /// <param name="requestUrl">API请求地址</param>
        /// <param name="trend_name">话题关键词</param>
        /// <returns>话题数据.</returns>
        public TimelineData GetTrends(string requestUrl, string trend_name)
        {
            this.Clear();
            this.Parameters.Add("trend_name", trend_name);
            return this.GetResponseData<TimelineData>(requestUrl);
        }
        #endregion
    }
}
